<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require_once(dirname(__FILE__) . "/../../dbcom/StaisCom.php");
require_once(dirname(__FILE__) . "/../../dbcom/CustomerCom.php");
require_once(dirname(__FILE__) . "/../../common/Common.php");

$staiscom = new StaisCom();
$customercom = new CustomerCom();
$common = new Common();

$num0 = $staiscom->getNumberByStais(0);
$num1 = $staiscom->getNumberByStais(1);
$num2 = $staiscom->getNumberByStais(2);

$staisarr = $staiscom->getAllStais();
$res = array();
if(!empty($staisarr)){
    foreach($staisarr as $k=>$v){
        $res[$k]['des'] = $v['des'];
        switch ($v['satisfied']){
            case 0:
                $res[$k]['sta'] = "满意";
                break;
            case 1:
                $res[$k]['sta'] = "基本满意";
                break;
            case 2:
                $res[$k]['sta'] = "不满意";
                break;
            default :
                $res[$k]['sta'] = "未知";
                break;
        }
    }
}

?>

<!DOCTYPE html>
<html>

    <head>

        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="keywords" content="">
        <meta name="description" content="">
        <link href="../public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
        <link href="../public/css/font-awesome.css?v=4.4.0" rel="stylesheet">

        <link href="../public/css/animate.css" rel="stylesheet">
        <link href="../public/css/style.css?v=4.1.0" rel="stylesheet">

        <link href="../public/css/paging.css" rel="stylesheet">
        <link href="../public/css/showproject.css" rel="stylesheet">
    </head>

    <body class="gray-bg">

        <div class="wrapper wrapper-content animated fadeInUp">
            <div class="row">
                <div class="col-sm-12">

                    <div class="ibox">
                        <div class="ibox-title">
                            <h5>满意度统计</h5>
                            <div class="ibox-tools">

                            </div>
                        </div>
                        <div class="ibox-content" style="height:800px;">
                            <div class="row m-b-sm m-t-sm">
                                <div class="col-md-1">

                                </div>
                                <div class="col-md-11">
                                    <div class="input-group">

                                    </div>
                                </div>
                            </div>

                            <div class="project-list">
                                <!--                                内容-->
                                <div id="main" style="width: 50%;height:700px;float:left;"></div>
                                <div id="text" style="width: 50%;max-height:700px;float:left;overflow: hidden;">
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>满意度</th>
                                                <th>意见反馈</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php foreach($res as $vv){ ?>
                                            <tr>
                                                <td><?= $vv['sta'] ?></td>
                                                <td><?= $vv['des'] ?></td>
                                            </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>




        <!-- 全局js -->
        <script src="../public/js/jquery.min.js?v=2.1.4"></script>
        <script src="../public/js/bootstrap.min.js?v=3.3.6"></script>
        <script src="../public/js/plugins/layer/layer.min.js"></script>
        <script src="../public/js/echarts.js"></script>

        <!-- 自定义js -->
        <script src="../public/js/paging.js?v=1.0.0"></script>
        <script src="../public/js/upload.js?v=1.0.0"></script>
        <script src="../public/js/common.js?v=1.0.0"></script>

        <script>
            $(document).ready(function () {

                $('#loading-example-btn').click(function () {
                    btn = $(this);
                    simpleLoad(btn, true)

                    // Ajax example
                    //                $.ajax().always(function () {
                    //                    simpleLoad($(this), false)
                    //                });

                    simpleLoad(btn, false)
                });
            });
            function simpleLoad(btn, state) {
                if (state) {
                    btn.children().addClass('fa-spin');
                    btn.contents().last().replaceWith(" Loading");
                } else {
                    setTimeout(function () {
                        btn.children().removeClass('fa-spin');
                        btn.contents().last().replaceWith(" Refresh");
                    }, 2000);
                }
            }
            var myChart = echarts.init(document.getElementById("main"));
            option = {
                title: {
                    text: '滿意度調查',
                    subtext: '',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    // orient: 'vertical',
                    // top: 'middle',
                    bottom: 10,
                    left: 'center',
                    data: ['不滿意', '基本滿意', '滿意']
                },
                series: [
                    {
                        name: '满意度统计',
                        type: 'pie',
                        radius: '65%',
                        center: ['50%', '50%'],
                        selectedMode: 'single',
                        data: [
                            {value: <?= $num2 ?>, name: '不滿意'},
                            {value: <?= $num1 ?>, name: '基本滿意'},
                            {value: <?= $num0 ?>, name: '滿意'}
                        ],
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            myChart.setOption(option);
        </script>

    </body>
</html>